package com.sun.controller;


import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.zhku.meeting.api.LoginServiceApi;
import com.zhku.meeting.entities.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@CrossOrigin
@RestController
public class LoginController {

    @Resource
    private LoginServiceApi loginService;

    @RequestMapping("/login")
    @HystrixCommand(fallbackMethod = "login2")
    public Msg login(@RequestBody Map<String , Object> para){
        return loginService.login(para);
    }

    @RequestMapping("/login1")
    public void login1(){
        System.out.println("sun");
    }

    //备选方案
    public Msg login2(@RequestBody Map<String , Object> para){
        Msg msg = new Msg();
        msg.setError("账号或者密码不正确！");
        msg.setCode(100_000);
        return msg;
    }


}
